/**
 * 
 */
export const isEmpty = (val: any) : boolean => {
	if(Array.isArray(val)) {
		return val.length === 0
	}
	if(val instanceof Object) {
		return Reflect.ownKeys(val).length === 0
	}
	return !val
}

/**
 * 对象转URL
 * @param {object} obj
 */
export const parseParamsToUrl = (obj:any = {}) :string => {
	if(isEmpty(obj)) {
		return ''
	}
	return Reflect.ownKeys(obj).reduce(
		(acc:string, cur: string | number | symbol, i : number):string  => {
			if(obj[cur] && typeof cur === 'string') {
				return  `${acc}${i > 0 && '&' || ''}${cur}=${obj[cur]}`
			}
			return acc
		}
	, '?')
}